﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SMS.Domain;
using SMS.Domain.Model;

namespace SMS.Shell.Windows
{
    /// <summary>
    /// Interaction logic for SelectCustomerWindow.xaml
    /// </summary>
    public partial class SelectCustomerWindow : Window
    {
        public Customer SelectedCustomer { get; set; }
        public SelectCustomerWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(CargoListView_Loaded);
        }

        void CargoListView_Loaded(object sender, RoutedEventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            _gridCustomer.ItemsSource = new SmsService().FindCustomers();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void _btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            SelectedCustomer = _gridCustomer.SelectedItem as Customer;
            if (SelectedCustomer != null)
            {
                DialogResult = true;
            }
        }
    }
}
